package com.yahoo.labs.snow.solver;

import com.yahoo.labs.snow.ProblemInstance;

/**
 * Iteratively picks pivots, builds a good snowflake around each pivot, then picks another pivot.
 * 
 * @author chato
 * 
 */
public abstract class MultiplicativeEffortProduceAndChooseSolver extends ProduceAndChooseSolver {

	/**
	 * When requested N snowflakes, it produces N times this many snowflakes.
	 */
	final double DEFAULT_NUMCANDIDATES_MULTIPLIER = 2.0;
	
	double numCandidatesMultiplier;
	
	public MultiplicativeEffortProduceAndChooseSolver(ProblemInstance problem) {
		super(problem);
		setNumCandidatesMultiplier(DEFAULT_NUMCANDIDATES_MULTIPLIER);
	}

	public void setNumCandidatesMultiplier( double numCandidatesMultiplier ) {
		this.numCandidatesMultiplier = numCandidatesMultiplier;
	}
	
	@Override
	public int numToProduce(int requestedSnowflakes) {
		return (int)Math.min(requestedSnowflakes * numCandidatesMultiplier, problem.numNodes());
	}
}
